const initState = {
  count:0
}

const ADD_NUM = 'ADD_NUM'
const REMOVE_NUM = 'REMOVE_NUM'

export function reducer(state=initState,action) {
  switch(action.type) {
    case REMOVE_NUM :
      return {...state,count:state.count - 1 }
    case ADD_NUM:
      return {...state,count:state.count + 1}
    default:
      return initState
  }
}

export function add_num() {
  return {type:ADD_NUM}
}
export function remove_num() {
  return {type:REMOVE_NUM}
}

export function waitAdd() {
  return dispatch => {
		setTimeout(function () {
			dispatch({type: ADD_NUM})
		}, 1000)
	}
}

export function addTwice() {
  return [{type:ADD_NUM},{type:ADD_NUM}]
}